package com.dmitriyp.movie.editor;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IPersistableElement;

import com.dmitriyp.movie.mapping.Movie;

public class MovieEditorInput implements IEditorInput {

	private final Movie movie;
	
	public MovieEditorInput(Movie movie) {
		this.movie = movie;
	}
	
	@Override
	public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
		return null;
	}

	@Override
	public boolean exists() {
		return false;
	}

	@Override
	public ImageDescriptor getImageDescriptor() {
		return null;
	}

	@Override
	public String getName() {
		return "New Movie";
	}

	@Override
	public IPersistableElement getPersistable() {
		return null;
	}

	@Override
	public String getToolTipText() {
		return "Tool tip";
	}

	@Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + movie.hashCode();
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        MovieEditorInput other = (MovieEditorInput) obj;
        if (movie == null && other.movie != null)
            return false;
        return movie.equals(other.movie);
    }
    
    public Movie getMovie() {
		return movie;
	}
}
